<template>
  <j-modal
    :title="title"
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
    
    <a-spin :spinning="confirmLoading">
      <a-form-model ref="form" :model="model" :rules="validatorRules">
      
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="xmlName" label="xml名字">
          <a-input placeholder="请输入xml名字" v-model="model.xmlName" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="xmlType" label="xml类型">
          <a-input placeholder="请输入xml类型" v-model="model.xmlType" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="delFlag" label="是否启用 ">
          <a-input placeholder="请输入是否启用 " v-model="model.delFlag" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentname" label="设备名称">
          <a-input placeholder="请输入设备名称" v-model="model.equipmentname" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="subsystemname" label="分系统名称">
          <a-input placeholder="请输入分系统名称" v-model="model.subsystemname" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentcode" label="设备代号">
          <a-input placeholder="请输入设备代号" v-model="model.equipmentcode" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="grabf" label="数据采集频率">
          <a-input placeholder="请输入数据采集频率" v-model="model.grabf" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="maxPacketNum" label="图像合并数据数量">
          <a-input placeholder="请输入图像合并数据数量" v-model="model.maxPacketNum" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="kafkaTableName" label="复帧配置">
          <a-input placeholder="请输入复帧配置" v-model="model.kafkaTableName" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="imageParseMethod" label="图像帧解析方案，1无容器，2高微柜">
          <a-input placeholder="请输入图像帧解析方案，1无容器，2高微柜" v-model="model.imageParseMethod" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="imageDataLen" label="图像数据库的长度">
          <a-input placeholder="请输入图像数据库的长度" v-model="model.imageDataLen" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="deviceName" label="devicename">
          <a-input placeholder="请输入devicename" v-model="model.deviceName" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="secondSegment" label="二级索引的segment">
          <a-input placeholder="请输入二级索引的segment" v-model="model.secondSegment" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dataSegment" label="数据segment">
          <a-input placeholder="请输入数据segment" v-model="model.dataSegment" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="imgSegment" label="图像segment">
          <a-input placeholder="请输入图像segment" v-model="model.imgSegment" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="packageName" label="包名称">
          <a-input placeholder="请输入包名称" v-model="model.packageName" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sc" label="舱段或飞行器标识（产生舱段）">
          <a-input placeholder="请输入舱段或飞行器标识（产生舱段）" v-model="model.sc" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dty" label="文件标志">
          <a-input placeholder="请输入文件标志" v-model="model.dty" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="apid" label="文件名的apid">
          <a-input placeholder="请输入文件名的apid" v-model="model.apid" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ssid" label="文件名的ssid">
          <a-input placeholder="请输入文件名的ssid" v-model="model.ssid" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sdty" label="文件名的ssty">
          <a-input placeholder="请输入文件名的ssty" v-model="model.sdty" />
        </a-form-model-item>
		
      </a-form-model>
    </a-spin>
  </j-modal>
</template>

<script>
  import { httpAction } from '@/api/manage'
  import moment from "moment"

  export default {
    name: "GdqvXmlModal",
    data () {
      return {
        title:"操作",
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },

        confirmLoading: false,
        validatorRules:{
        },
        url: {
          add: "/test/gdqvXml/add",
          edit: "/test/gdqvXml/edit",
        },
      }
    },
    created () {
    },
    methods: {
      add () {
        //初始化默认值
        this.edit({});
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      close () {
        this.$emit('close');
        this.visible = false;
        this.$refs.form.clearValidate();
      },
      handleOk () {
        const that = this;
        // 触发表单验证
         this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })
          }else{
             return false;
          }
        })
      },
      handleCancel () {
        this.close()
      },


    }
  }
</script>

<style lang="less" scoped>

</style>